/**
 * @type {String}
 *
 * @properties={typeid:35,uuid:"0A72EE2E-942A-4E75-91DC-BBACBD798082"}
 */
var fError = null;

/**
 * @type {String}
 *
 * @properties={typeid:35,uuid:"46BD600B-1884-4239-A386-B0B65626FDBA"}
 */
var fUser = null;

/**
 * @type {String}
 *
 * @properties={typeid:35,uuid:"0A34E891-B21C-43C4-8013-C22C8A977FE5"}
 */
var fPass = null;

/**
 *
 * @properties={typeid:24,uuid:"0F6B6C23-BB83-45B7-8142-CD20A9371692"}
 * @AllowToRunInFind
 */
function Entrar()
{
	var ok = security.authenticate("mod_login_auth_fact_elec","autenticar",[fUser,fPass]) 
	if (ok == 1)
	{
		return true
	}
	else
	{
		switch (ok)
		{
			case 2:
			{
				//globals.DIALOGS.showErrorDialog('Error','Usuario incorrecto o permiso denegado','OK')
				fError = '*Permiso denegado'
				break;
			}
			case 3:
			{
				//globals.DIALOGS.showErrorDialog('Error','*Contraseña incorrecta','OK')
				fError = '*Contraseña incorrecta'
				break;
			}
			case 4:
			{
				//globals.DIALOGS.showErrorDialog('Error','Usuario no existe','OK')
				fError = '*Empresa no existe'
				break;
			}
		}
	return false
	}
}

/**
 * Callback method for when form is shown.
 *
 * @param {Boolean} firstShow form is shown first time after load
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"7CEFF1B9-709A-4F79-B7E2-FB260BFECC62"}
 */
function onShow(firstShow, event) {
	elements.lbl_solucion.text = application.getSolutionName().toUpperCase()
	elements.gLoginUserv.requestFocus()
}

/**
 * Handle hide window.
 *
 * @param {JSEvent} event the event that triggered the action
 *
 * @returns {Boolean}
 *
 * @properties={typeid:24,uuid:"BADA1875-0FF5-45BC-ACD2-2AEF3890420C"}
 */
function onHide(event) {
	if (security.getUserName() == null)
		return false
		
	return true
}

/**
 * Perform the element default action.
 *
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"22D6EBF9-9D5B-4901-989C-6FDCE66FE507"}
 */
function salir(event) {
	application.exit()
}
